<template>
  <div>
    <el-row style="padding-top:30px;padding-left:30px;">
      <el-col :span="12">
        <el-card :body-style="{padding:'0px',height:'180px'}">
          <div slot="header" class="clearfix">
            <i class="el-icon-caret-right" style="color:red"></i>
            <span style="line-height: 10px;">审核意见</span>
            <span style="padding-left:20px;font-size:12px;color:#C0CCDA;">不大于100个字符</span>
          </div>
          <el-row>
            <el-col :span="24">
              <el-input
                type="textarea"
                :rows="8"
                placeholder="请输入内容"
                :maxlength="100"
                :autofocus="true"
                :autosize="false"
                resize="none"
                v-model="opinion" >
              </el-input>
            </el-col>
          </el-row>
          <el-row style="height:50px;line-height:50px;">
            <el-col :span="4" :offset="1">
              审核类型：
            </el-col>
            <el-col :span="18">
              <el-radio-group v-model="auditType">
                <el-radio :label="true">通过审核</el-radio>
                <el-radio :label="false">退回重填</el-radio>
              </el-radio-group>
            </el-col>
          </el-row>
        </el-card>
        <el-row style="text-align: center;padding-top:30px;">
          <el-col :span="6" :offset="4" >
            <el-button type="success" @click="submitAudit">提交</el-button>
          </el-col>
          <el-col :span="6">
            <el-button type="warning" @click="reset">重置</el-button>
          </el-col>
        </el-row>
      </el-col>
    </el-row>
  </div>
</template>
<script>
import {mapActions,mapGetters} from 'vuex'
export default {
  props: ["propId","propReportId"],
  computed: {
    ...mapGetters(["auditLevel"])
  },
  data() {
    return {
      auditType: true,
      opinion: ""
    };
  },
  methods: {
    submitAudit() {
      if (this.opinion === "") {
        this.$message({
          message: "请输入审核意见！",
          type: "warning"
        });
        return false;
      }
      let url = this.auditLevel === 0 ? '/gov/report/deal' : '/gov/report/replacedeal';
      var params = {
        id: this.propReportId,
        state: this.auditType,
        opinion: this.opinion,
        groupLevel: this.auditLevel,
      };
      new Promise((resolve, reject) => {
        this.$http
          .fetchPost(url, params)
          .then(response => {
            if(response.errorCode === '0'){
              this.$message({
                message: '审核成功！',
                type: 'success'
              });
            }else{
              this.$message.error(response.errorMessage);
            }
            resolve(response);
            this.$emit("pickFatherFounction");
          }, error => {
            reject(error);
          });
      });
    },
    reset() {
      this.auditType = true;
      this.opinion = '';
    }
  }
};
</script>
<style scoped>
button {
  width: 80px;
  height: 35px;
}
</style>
